﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SubSonic;
using CXDB;
using Coolite.Ext.Web;
public partial class Search_Provider_Apply : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Store1Databind();
        }
        CXSecurity.ChekBigBoss();
    }
    protected void Store1_OnRefreshData(object s, StoreRefreshDataEventArgs e)
    {
        Store1Databind();
    }
    protected void Allow(object s, AjaxEventArgs e)
    {
        if (e.ExtraParams["cmd"].ToLower() == "detailshow")
        {
            Ext.MessageBox.Show(new MessageBox.Config
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.INFO,
                Title = "详细原因",
                Message = e.ExtraParams["reason"].ToString(),
                Width = 300
            });
        }
        else
        {
            CxApply cx = new CxApply("id", e.ExtraParams["id"]);
            cx.BossID = int.Parse(Cookies.getCookies("cuid"));
            cx.BossTime = DateTime.Now;
            if (e.ExtraParams["cmd"].ToLower() == "allow")
            {
                cx.BossNod = 1;
            }
            if (e.ExtraParams["cmd"].ToLower() == "unallow")
            {
                cx.BossNod = 2;
            }
            cx.Save();
            Ext.MessageBox.Show(new MessageBox.Config
            {
                Buttons = MessageBox.Button.OK,
                Icon = MessageBox.Icon.INFO,
                Title = "操作",
                Message = "成功！"
            });
        }

    }
    protected void Store1Databind()
    {
        Query q = new Query(VwApplyProvider.Schema);
        q.SetSelectList(
            "id,reason,status,intime,bossnod,bosstime,usertime,providername,devicename,dept_master_status,office_master_status,tech_master_status,boss_status,username,deptname");
        q.ORDER_BY("id desc");
        Store1.DataSource = q.ExecuteDataSet();
        Store1.DataBind();
    }
}
